<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@include file="../../common/operation_forbid.jsp" %>
<%@include file="../../common/jsVersion.jsp"%>
<c:set var="contextPath" value="${pageContext.request.contextPath}"/>
<script type="text/javascript">
    var contextPath = '${contextPath}';
    var shouStatus = '${shouStatus}';
    var subscribeId='${subscribeId}';
    var documentType=${documentType};
    var paymentMethods=${paymentMethods};
    var contactTypes=${contactTypes};
    var processFlag='${processFlag}';
    var userName="${userName}";
	var haveReceivedPayDepositAmount=0;
	var currentUserName='小张';
	var currentUserId='1';
	var process = '${process}';
    var returnUrl = '${returnUrl}';
    var auditStatus = '${auditStatus}';
    var businessStatus = '${businessStatus}';
    var oldSignedId = '${oldSignedId}';
    var businessSecStatus = '${businessSecStatus}';
    var businessAbnormaId = '${businessAbnormaId}';
    var procInstId = '${procInstId}';
    var huanStatus = '${huanStatus}'; 
    var returnBackParam="${returnBackParam}";
    var payDepositOff=${payDepositOff};
</script>
<!DOCTYPE html >
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>签约详情</title>
    <!-- neptune -->
    <%@include file="../../common/extInclude.jsp" %>
    <script type="text/javascript" src="${contextPath}/static/js/customer/signed/view.js?v=${jsVersion}"></script>
    <script type="text/javascript" src="${contextPath}/static/js/marketing/changecontact/signedcontactchange.js?v=${jsVersion}"></script>
          <script type="text/javascript" src="${contextPath}/static/js/components/processHistory.js?v=${jsVersion}"></script>
     <script type="text/javascript" src="${contextPath}/static/js/jquery/json2.js"></script> 
     <script type="text/javascript" src="${contextPath}/static/js/components/fileComponent.js?v=${jsVersion}"></script>
    <script type="text/javascript">
 	var menu = '${menu}';
 	var idata = '${permitBtn}';
 	var contactChangeFlag = ${contactChangeFlag};
 	if(idata!=null||idata!=""){
		idata=JSON.parse(idata);
	}
 	//签约收款 、合同变更、换房
 	var marketingSignedReceivables= true ;
 	var marketingSignedChangeHouse=true ;
 	var marketingSignedcontractChange= true ;
 	var marketingSignedTuiHouse=true;
 	var marketingSigendGengName=true;
 	var marketingSigendTuiFang=true;
 	var marketingSigendHuanFang=true;
 	var marketingSignedShou=true;
 	var marketingDeferredPayment=true;
 	
  	if(processFlag=="false"){
	 	if(Ext.Array.contains(idata,"marketing:signed:receivables")){
	//  		marketingSignedReceivables=false;

	 		if(auditStatus=="3"&&shouStatus=="0" && businessStatus !="2" && businessSecStatus!="3"){
	 			marketingSignedReceivables = false;
	 		}else{
	 			marketingSignedReceivables = true;
	 		}
	 	}
	 	if(Ext.Array.contains(idata,"fin:haveReceive:delayReceivables")){
	 		//当审核通过才能显示延期收款按钮
	 		if(auditStatus=="3"&&businessStatus!="2" && businessSecStatus!="2" && businessSecStatus!="3"){
	 			marketingDeferredPayment = false;
	 		}
	 		
	 	}
		if(Ext.Array.contains(idata,"marketing:signed:contractChange")){
			//权限
			if(auditStatus=="3"&&businessStatus!="2" && businessSecStatus!="2" && businessSecStatus!="3"){
				marketingSignedcontractChange=false;
				//1、权限通过,显示合同变更按钮
				//2、是否存在已收款状态交给权限按钮
				marketingSignedcontractChange = contactChangeFlag;
			}else{
				marketingSignedcontractChange=true;
			}
	 	}
		if(Ext.Array.contains(idata,"marketing:signed:changeHouse")){
			if(auditStatus=="3"&&businessStatus!="2" && businessSecStatus!="2" && businessSecStatus!="3"){
				marketingSignedChangeHouse=false;
			}else{
				marketingSignedChangeHouse=true;
			}
	 	}
		if(Ext.Array.contains(idata,"marketing:signed:retreatHouse")){
			if(auditStatus=="3"&&businessStatus!="2" && businessSecStatus!="2" && businessSecStatus!="3"){
				marketingSignedTuiHouse=false;
			}else{
				marketingSignedTuiHouse=true;
			}
		}
		if(Ext.Array.contains(idata,"marketing:signed:changeHouseName")){
			if(auditStatus=="3"&&businessStatus!="2" && businessSecStatus!="2" && businessSecStatus!="3" ){
				marketingSigendGengName=false;
			}else{
				marketingSigendGengName=true;
			}
		}
		if(businessStatus=="2"){
			marketingSigendTuiFang=false;
		}else{
			marketingSigendTuiFang=true;
		}
		//是否显示换房信息
		if(businessSecStatus == "3" || oldSignedId != ""){
			marketingSigendHuanFang=false;
		}else{
			marketingSigendHuanFang=true;
		}
	  	//收款明细 
	  	if(Ext.Array.contains(idata,"marketing:signed:receivablesDetail")){
	  		if(auditStatus=="3"){
	  			marketingSignedShou = false;
	  		}	
	  	}
		
  	}
    </script>
</head>
<script type="text/javascript">
function initSignedFile(httpUrl){
	if(null==httpUrl || httpUrl=="")return;
	var imgsArray=httpUrl.split("|");
	for(var i=0;i<imgsArray.length;i++){
		var rowFileUrl=imgsArray[i];
		var imgs="<a href='"+rowFileUrl+"' target='_blank'><img style='width: 80px; height: 90px;' src='"+rowFileUrl+"'/></a>";
		var imgPanel = Ext.create("Ext.Panel", {
	        html: imgs
		})
		var showImgPanel=Ext.getCmp("signedFileFormPanel");
		showImgPanel.add(imgPanel);
	}
	
	Ext.getCmp("signedFileForm").show();
}
Ext.onReady(function() {
	var viewPanel=Ext.create("customer.subscribe.viewPanel");
 	var estateRecord=${estateRecord};
 	var customerRecord=${customerRecord};
 	var signedRecord=${signedRecord};  
	//初始化值
	viewPanel.getComponent("estatePanel").getForm().setValues(estateRecord);
 	viewPanel.getComponent("customerPanel").getForm().setValues(customerRecord);
 	viewPanel.getComponent("subscribeInfoForm").getForm().setValues(signedRecord);
 	var back = "${back}";
  	if(back=="error"){
  		Ext.getCmp("retrunBtn").setVisible(false);
    }else{
    	Ext.getCmp("retrunBtn").setVisible(true);
    }
 	initSignedFile(signedRecord.signedFileUrl);

 	//设置合同总金额
    // Ext.getCmp("signAmount").setValue(signedRecord.signAmount + signedRecord.decorationMoney);
    Ext.getCmp("signAmount").setValue(signedRecord.signAmount );
	//设置房款金额
	Ext.getCmp("roomTotalAmount").setValue(signedRecord.signAmount);
	//设置装修款
	Ext.getCmp("decorationMoneyAmount").setValue(signedRecord.decorationMoney);
	
 	Ext.getCmp("didTime").setValue(Ext.Date.format(new Date(signedRecord.didTime),'Y-m-d'));
 	var process = '${process}';
 	//流程审批时候 隐藏按钮
 	if(process!=null&&process!=""){
 		Ext.getCmp("proceedsBut").setVisible(false);
 	}
 	/** 这段代码没地方使用
 	//审核历史,展示当前审核状态
	var currAutidStatus = "";
	if(auditStatus == "0"){
		currAuditStatus = "<font style='color: red;'>待提交</font>";
	}else if(auditStatus == "1"){
		currAuditStatus = "<font style='color: red;'>审核中</font>";
	}else if(auditStatus == "2"){
		currAuditStatus = "<font style='color: red;'>已退回</font>";
	}else if(auditStatus == "3"){
		currAuditStatus = "<font style='color: red;'>已通过</font>";
	}
 	Ext.getCmp("currAuditStatus").setValue(currAuditStatus);
 	**/
 	
	
 	if(processFlag=="true" || processFlag==true){
 		Ext.getCmp("retrunBtn").setVisible(false);
 		//审批历史隐藏
 		Ext.getCmp("historyPanel").setVisible(false);
 		marketingSignedShou = true;
 	}
 	
});
</script>
<body>
</body>
</html>